/*
 * @Author: Soulmate
 * @Date: 2023-10-18 09:23:20
 * @LastEditTime: 2023-10-19 08:51:24
 * @LastEditors: Soulmate
 * @Description: 
 * @FilePath: \ruoyi-ui-vue3\src\utils\map.ts
 * 版权声明
 */
/**
 * 生成地图控件的钩子
 * @param obj 
 */
export function createControlHtml(obj) {
    let buttonGroup = '';
    let { className, groups } = obj;
    let _container = document.querySelectorAll(`.${className}`)[0] as HTMLElement;
    groups.forEach(element => {
        //多边形
        var dom = document.createElement(element.tag);
        dom.id = element.id;
        dom.className = `${element.class} commonControl`;
        dom.title = element.title;
        if (element.hasButtons) {
            buttonGroup = `<div id="${element.buttons.id}" class="${element.buttons.class} commonControlConfirm">` + element.buttons.children.map(item => { return `<span>${item}</span>` }).join('') + `</div>`;
        } else { 
            buttonGroup = '' 
        }
        dom.innerHTML = `<img src="${new URL(`../assets/icons/svg/${element.svgIcon}`, import.meta.url).href}" style="width: ${element.size ?? 14}px" />${buttonGroup}`;
        _container.appendChild(dom);
    });
}